<template>
  <a-drawer
    :title="title"
    :width="720"
    :visible="visible"
    :wrapStyle="{height: '100%',overflow: 'auto',paddingBottom: '108px'}"
    @close="close"
  >
    <!-- table区域 -->
    <div>

      <s-table
        ref="table"
        rowKey="id"
        :columns="columns"
        :data="loadData"
      >

        <span slot="action" slot-scope="text, record">
          <a @click="edit(record)">编辑</a>
          <a-divider type="vertical"/>
          <a-popconfirm title="确定删除吗?" @confirm="() => del(record.id)">
            <a>删除</a>
          </a-popconfirm>
        </span>
      </s-table>
    </div>

    <commodity-modal ref="modal" @ok="refreshTable"></commodity-modal>
  </a-drawer>
</template>

<script>
import { ListMixin } from '@/mixins/ListMixin'
import CommodityModal from './CommodityModal'

import { COMMODITY_ISSUE_STATUS_ENUM } from '@/store/mutation-types'
import { apiQueryCommodityLogList } from '@/api/commodity'

const columns = [
  {
    title: '操作人员',
    dataIndex: 'operatorName',
    key: 'operatorName'
  },
  {
    title: '操作时间',
    dataIndex: 'operateDate',
    key: 'operateDate'
  },
  {
    title: '信息变更',
    dataIndex: 'operateTypeDesc',
    key: 'operateTypeDesc'
  }
]

export default {
  name: 'CommodityList',
  components: {
    CommodityModal
  },
  mixins: [ListMixin],
  data () {
    return {
      title: '操作日志',
      visible: false,
      issueStatusEnum: COMMODITY_ISSUE_STATUS_ENUM,
      columns,
      commodityId: null,
      loadData: parameter => {
        return apiQueryCommodityLogList(this.commodityId, Object.assign(parameter, this.queryParam)).then(res => {
          return res
        })
      }
    }
  },
  methods: {
    show (title, record) {
      this.title = title
      this.commodityId = record.id
      this.visible = true
      this.$nextTick(() => {
        this.refreshTable()
      })
    },
    close () {
      this.visible = false
    }
  }
}
</script>

<style scoped>

</style>
